<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="include :: header('修改包模板')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-ooziePackageTemplate-edit" th:object="${ooziePackageTemplate}">
            <input id="packageId" name="packageId" th:field="*{packageId}" type="hidden">
			<input id="projectId" name="projectId" th:field="*{projectId}" type="hidden">
			<div class="form-group">	
				<label class="col-sm-3 control-label">包名(en)：</label>
				<div class="col-sm-8">
					<input id="nameEn" disabled name="nameEn" th:field="*{nameEn}" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">包名(cn)：</label>
				<div class="col-sm-8">
					<input id="nameCn" name="nameCn" th:field="*{nameCn}" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">Hive2认证：</label>
				<div class="col-sm-8">
					<div class="onoffswitch">
						<input type="checkbox" class="onoffswitch-checkbox" name="conHive2Id" id="conHive2Id" th:checked="${ooziePackageTemplate.conHive2Id == 'on' ? true : false}">
						<label class="onoffswitch-label" for="conHive2Id">
							<span class="onoffswitch-inner"></span>
							<span class="onoffswitch-switch"></span>
						</label>
					</div>
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">Hcat认证：</label>
				<div class="col-sm-8">
					<div class="onoffswitch">
						<input type="checkbox" class="onoffswitch-checkbox" name="conHcatalogId" id="conHcatalogId" th:checked="${ooziePackageTemplate.conHcatalogId == 'on' ? true : false}">
						<label class="onoffswitch-label" for="conHcatalogId">
							<span class="onoffswitch-inner"></span>
							<span class="onoffswitch-switch"></span>
						</label>
					</div>
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">Hbase认证：</label>
				<div class="col-sm-8">
						<div class="onoffswitch">
							<input type="checkbox" class="onoffswitch-checkbox" name="conHbaseId" id="conHbaseId" th:checked="${ooziePackageTemplate.conHbaseId == 'on' ? true : false}">
							<label class="onoffswitch-label" for="conHbaseId">
								<span class="onoffswitch-inner"></span>
								<span class="onoffswitch-switch"></span>
							</label>
						</div>
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">描述：</label>
				<div class="col-sm-8">
					<textarea id="note" name="note" class="form-control" th:field="*{note}"></textarea>
				</div>
			</div>
		</form>
    </div>
    <div th:include="include::footer"></div>
    <script type="text/javascript">
		var prefix = ctx + "oozie/ooziePackageTemplate";
        $(document).ready(function(){
            $("#form-ooziePackageTemplate-add").validate({
                rules:{
                    nameEn:{
                        minlength: 6,
                        maxlength: 20,
                        remote: {
                            url: prefix + "/checkPackageNameUnique",
                            type: "post",
                            dataType: "json",
                            data: {
                                nameEn : function() {
                                    return $.common.trim($("#nameEn").val());
                                }
                            },
                            dataFilter: function(data, type) {
                                return $.validate.unique(data);
                            }
                        },
                        checkName: true
                    },
                    nameCn: {
                        required:true,
                        minlength: 2,
                        maxlength: 20,
                    },
                    packageType: {
                        required:true
                    }
                },
                focusCleanup: true
            });

            $.validator.addMethod("checkName",function(value,element,params){
                var checkName = /^\w{2,50}$/g;
                return this.optional(element)||(checkName.test(value));
            },"*只允许2-50位英文字母、数字或者下画线！");
        });
		
		function submitHandler() {
	        if ($.validate.form()) {
	            $.operate.save(prefix + "/edit", $('#form-ooziePackageTemplate-edit').serialize());
	        }
	    }
	</script>
</body>
</html>
